package com.itheima.job.test06;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;
import java.util.UUID;

public class TCPClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",12345);

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day15_inter\\fj.jpg"));
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);
        int b;
        while ((b=bis.read())!=-1){
            bos.write(b);
        }
        socket.shutdownOutput();

        InputStream is = socket.getInputStream();
        BufferedInputStream serverBis = new BufferedInputStream(is);
        BufferedOutputStream bos1 = new BufferedOutputStream(new FileOutputStream("day15_inter\\copy\\"+ UUID.randomUUID()+".jpg"));
        int a ;
        while ((a = serverBis.read())!=-1){
            bos1.write(a);
        }
        bos1.close();

        System.out.println("发送成功");

        socket.close();

    }
}
